import 'package:flutter/material.dart';
import 'package:myapp/pages/homePage.dart';
import 'package:myapp/pages/myScaffold.dart';
import 'package:myapp/pages/newRoute.dart';
import 'package:myapp/pages/tipRoute.dart';

void main() => runApp(new MyScaffold());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
        title: 'Flutter Demo',
        theme: new ThemeData(primarySwatch: Colors.blue),
        // home: new HomePage(title: '首页'),
        initialRoute: "/",
        routes: {
          "new_page": (context) => NewRoute(),
          "/": (context) => HomePage(title: 'Flutter Home Page'),
          "tip_page": (context) =>
              TipRoute(text: ModalRoute.of(context).settings.arguments),
          "my_app_bar": (context) =>
              TipRoute(text: ModalRoute.of(context).settings.arguments)
        },
        onGenerateRoute: (RouteSettings settings) {
          return MaterialPageRoute(builder: (context) {
            String routeName = settings.name;
            print(routeName);
            // 如果访问的路由页需要登录，但当前未登录，则直接返回登录页路由，
            // 引导用户登录；其它情况则正常打开路由。
          });
        });
  }
}
